<html>
<head><meta charset="utf-8"><title>Feature flags · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html">Feature flags</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="188368288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188368288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188368288">(Feb 17 2020 at 10:47)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> , might I ask you why we shouldn't expose feature flags structure to UI, <span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> and I are convinced that this affects UX... We would like to declare them in <code>package.json</code> at least temporarily, while we don't generate it from our source code</p>



<a name="188368417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188368417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188368417">(Feb 17 2020 at 10:49)</a>:</h4>
<p>I don't know what's the right answer here</p>



<a name="188368478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188368478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188368478">(Feb 17 2020 at 10:50)</a>:</h4>
<p>I would be 100% with generating that bit of settings from a Rust declaration</p>



<a name="188368491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188368491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188368491">(Feb 17 2020 at 10:50)</a>:</h4>
<p>I would be less OK with just manually syncing things, or keeping source of truth in package.json</p>



<a name="188368502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188368502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188368502">(Feb 17 2020 at 10:50)</a>:</h4>
<p>Opened <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3189" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/3189">https://github.com/rust-analyzer/rust-analyzer/issues/3189</a> for the overall configuration design discussion</p>



<a name="188369858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188369858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188369858">(Feb 17 2020 at 11:11)</a>:</h4>
<p>I think sync'ing them manually is fine for now because 1. this affects users right now, 2. there's very few of them, 3. if we use a prefix to differentiate these preferences, the client-side work to support it (notifying the server that a flag has changed) will be useful when switching to something generated automatically</p>



<a name="188369955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188369955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188369955">(Feb 17 2020 at 11:13)</a>:</h4>
<p>Yeah, that's reasonable. They reason why I am not 100% is that doing that relives pressure from this issue <strong>for VS Code</strong> and, all other things being equal, I'd prefer not to single out this editor more than it already is</p>



<a name="188370172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188370172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188370172">(Feb 17 2020 at 11:17)</a>:</h4>
<p>Still, generating the <code>package.json</code> parts automatically will not help other editors, will it? Because each LSP client will have a different way to configure these.</p>



<a name="188370227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188370227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188370227">(Feb 17 2020 at 11:18)</a>:</h4>
<p>It will, as it will also generate docs. But this is just a minor point</p>



<a name="188370495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188370495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188370495">(Feb 17 2020 at 11:23)</a>:</h4>
<p>Then a plan here might be to:</p>
<ol>
<li>manually add the settings to <code>package.json</code> and implement a way to toggle them from the Code extension</li>
<li>replace the server hashmap with a strongly-typed struct (alternatively, use a different self-documenting format)</li>
<li>extend <code>xtask</code> to read the doc comments on that struct (or the different format) and produce docs for them</li>
<li>extend <code>xtask</code> to generate the <code>package.json</code> stuff</li>
</ol>
<p>We could also describe them in e.g. JSON schema and optionally generate Rust code from that.</p>



<a name="188370633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188370633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188370633">(Feb 17 2020 at 11:25)</a>:</h4>
<p>SGTM, though I am not sure about 2. The problem main problem with strong types is that we want to separate LSP settings from analyzer settings. String types allow us to have a runtime dep there</p>



<a name="188371197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371197">(Feb 17 2020 at 11:35)</a>:</h4>
<p>We may declare feature flags structs specific to non-lsp crates and map lsp-feature-flags to non-lsp ones by <code>impl From</code>. Making them a hashmap I would think that we would want to dynamically mutate our feature flags, though this doesn't happen in practice, hence simple mapping is more convenient I think</p>



<a name="188371326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371326">(Feb 17 2020 at 11:37)</a>:</h4>
<p>Or store them in a struct on the server and use strings at the interface</p>



<a name="188371416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371416">(Feb 17 2020 at 11:39)</a>:</h4>
<p><span class="user-mention" data-user-id="258149">@std::Veetaha</span> generating code from the JSON schema should work, right?</p>



<a name="188371430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371430">(Feb 17 2020 at 11:40)</a>:</h4>
<p>Can it also store docs?</p>



<a name="188371489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371489">(Feb 17 2020 at 11:40)</a>:</h4>
<p>I'd rather avoid JSON schema and use the appoach we use to gen ast</p>



<a name="188371505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371505">(Feb 17 2020 at 11:41)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/xtask/src/ast_src.rs" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/master/xtask/src/ast_src.rs">https://github.com/rust-analyzer/rust-analyzer/blob/master/xtask/src/ast_src.rs</a></p>



<a name="188371519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371519">(Feb 17 2020 at 11:41)</a>:</h4>
<p>declare a rust  struct with a macro, generate things from this struct</p>



<a name="188371531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188371531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188371531">(Feb 17 2020 at 11:41)</a>:</h4>
<p>that avoids build-time dependency on parsing json/toml/ron whatever</p>



<a name="188375382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188375382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188375382">(Feb 17 2020 at 12:48)</a>:</h4>
<p>Jason schema do stores metadata "title", "description" props, tho I am totally okay with the approach we have in ast gen. But, @matklad, does my proposal with separating the API and mapping between different structs seem reasonable?</p>



<a name="188375405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188375405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188375405">(Feb 17 2020 at 12:49)</a>:</h4>
<p>It does, though I think hash-map vs typed API is a minor point here</p>



<a name="188375448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188375448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188375448">(Feb 17 2020 at 12:50)</a>:</h4>
<p>Like, I do thing that either would work fine, and that both would  be indistinguishable for users</p>



<a name="188375477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188375477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188375477">(Feb 17 2020 at 12:50)</a>:</h4>
<p>Right, indistinguishable, that's just a server impl detail</p>



<a name="188375501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188375501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188375501">(Feb 17 2020 at 12:51)</a>:</h4>
<p>Sorry, I might've missed the point</p>



<a name="188376369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188376369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188376369">(Feb 17 2020 at 13:05)</a>:</h4>
<p>Anyway, what was the initial reason we switched from Ron? By parsing Ron you mean time consuming?</p>



<a name="188376463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188376463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188376463">(Feb 17 2020 at 13:06)</a>:</h4>
<p>Mainly to improve compile times, and also to reduce overall complexity</p>



<a name="188529047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188529047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188529047">(Feb 19 2020 at 09:44)</a>:</h4>
<p>So, do we work on configuration design first? I don't think that adding feature flags declaration to <code>package.json</code> would be any noticeable tech debt, but it will give better ux in short term. Amending <code>package.json</code> is the least thing it requires...</p>



<a name="188531433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188531433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188531433">(Feb 19 2020 at 10:21)</a>:</h4>
<p>I am ok with r+ whatever changes to package.json/TS to make better short term. </p>
<p>For backend changes, I think I'll need to spend some time familiarizing myself with the relevant LSP APIs first, and that probably won't happen this week</p>



<a name="188531742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Feature%20flags/near/188531742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Feature.20flags.html#188531742">(Feb 19 2020 at 10:26)</a>:</h4>
<p>Okay, I'll add relevant feature flags to <code>package.json</code> then.</p>
<p>Also, as a side not, I'd suggest using <code>r+</code> word not so often, because this is very ad hoc.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>